<?php
session_start ();
require_once ("../commun/ouvre_base.php");

$_SESSION ['pathway'] = '..';
include_once ($_SESSION ['pathway'] . "/header.php");

// if(!isset($_GET['from']) or $_GET['from'] != 'entry'){ //c'est une entrée donc puisqu'on garde ancien onglet, pas besoin de fil d'ariane
// echo $_GET['from'];
?><p>
	<a href="<?php echo $_SESSION['pathway']; ?>/index.php">Home</a> > <a
		href="<?php echo $_SESSION['pathway']; ?>/genetiquespataxeurospa/consultation.php">Export
		Genetics </a> > <a href='#' onclick="history.back();"> Request results
	</a> > Edit
</p><?php
// }

if (! isset ( $_SESSION ['id'] ) or $_SESSION ['acces_genetique'] < 2) {
	echo "<table class='principale'><tr><td>Session expired</td></tr>";
	echo "<tr><td><a href='" . $_SESSION ['pathway'] . "/index.php'>Start</a></td></tr></table>";
} else {
	
	if (isset ( $_GET ['table'] ) and $_GET ['table'] != '' and isset ( $_GET ['fiche'] ) and $_GET ['fiche'] != '') {
		$table = $_GET ['table'];
		
		echo "<form action=" . $_SESSION ['pathway'] . "/edit.php?ind=" . $_GET ['fiche'] . "&amp;edit=" . $_GET ['fiche'] . "&amp;table=" . $_GET ['table'] . " method='post' enctype='multipart/form-data'>";
		echo "<table class='principale' cellspacing='1' cellpadding='3'>";
		
		$requete_fiche = "SELECT * FROM `" . $table . "`
		WHERE `index` LIKE " . $_GET ['fiche'] . ";";
		// ~ echo $requete_fiche;
		$result_requete_fiche = mysql_query ( $requete_fiche ) or die ( "Impossible de recupérer les entetes : " . mysql_error () );
		while ( $ligne = mysql_fetch_assoc ( $result_requete_fiche ) ) {
			
			foreach ( $ligne as $champ => $valeur ) {
				$hash_champ_valeur [$champ] = $valeur;
			}
		}
		
		$requete_recup_entete = "SELECT * FROM `" . $table . "_nom_champ`
		ORDER BY `ID_index_nom_champ` ASC";
		$result_recup_entete = mysql_query ( $requete_recup_entete ) or die ( "Impossible de recupérer les entetes : " . mysql_error () );
		$fin = "\" >";
		while ( $ligne = mysql_fetch_assoc ( $result_recup_entete ) ) {
			echo "<tr><td>" . $ligne ['nom_champ'] . "</td><td>" . $ligne ['type'] . $hash_champ_valeur [$ligne ['champ']];
			if (! preg_match ( "/ttached file/", $ligne ['nom_champ'] )) {
				echo $fin;
			}
			echo "</td></tr>";
		}
		
		echo "<tr><td><input type='submit' value='Save' /></td></tr>";
		echo "</table>";
		
		echo "</form>";
	} else {
		echo "Error : la table n'est pas renseignée";
	}
	
	$_POST = array ();
}

?>

